package org.dzq.designmode.adapter.objectadapter;

/**
 * @ClassName: ClassAdapter
 * @Package: org.dzq.designmode.adapter.classadapter
 * @author: 越
 * @date: 2023/6/13 21:48
 * @Description: 对象适配器：通过引用被适配者为属性并实现目标接口实现
 */
public class ObjectAdapter implements Target {

    private Adaptee adaptee;

    public ObjectAdapter(Adaptee adaptee){
        this.adaptee = adaptee;
    }

    @Override
    public int getPhoneVoltage() {
        int voltage = adaptee.getHomeVoltage();
        int phoneVoltage = voltage/44;//将220V家庭电压转化成5V的手机电压
        return phoneVoltage;
    }
}
